import Ajax from './customajax'

export default {
  updateElementXy(elementList) {
    const url = '/dirms/monitor/sysmap/update/element/x/y';
    return Ajax.save(url, elementList, false);
  },
    listMap() {
        const url = '/dirms/monitor/sysmap/all';
        return Ajax.save(url);
    },
    listMapByType(type) {
        const url = '/dirms/monitor/sysmap/getSysmapByType/' + type;
        return Ajax.save(url);
    },
    queryMapByName(name) {
        let sysmap = {};
        sysmap.name = name;
        const url = '/dirms/monitor/sysmap/getSysmapByName';
        return Ajax.save(url, sysmap, false);
    },
    syncQueryMapByName(params, callback) {
        const url = '/dirms/monitor/sysmap/getSysmapByName';
        return Ajax.syncQuery(url, params, callback);
    },
    queryMapDataById(sysmapid) {
        const url = '/dirms/monitor/sysmap/get/' + sysmapid;
        return Ajax.save(url);
    },
    queryImageByMapid(sysmapid) {
        const url = '/dirms/monitor/image/getByMapid/' + sysmapid;
        return Ajax.save(url);
    },
    querySysImage() {
        const url = '/dirms/monitor/image/getSysIcons';
        return Ajax.save(url);
    },
    updateMap(mapid, elementList) {
        const url = '/dirms/monitor/sysmap/update';
        return Ajax.save(url, elementList, false);
    },
    queryScriptByName(name) {
        const url = '/dirms/monitor/script/getByName/' + name;
        return Ajax.save(url);
    },
    executeScript(hostid, scriptid) {
        const url = '/dirms/monitor/script/excute/' + hostid + '/' + scriptid;
        return Ajax.save(url);
    },
    queryInterface() {
        const url = '/dirms/monitor/item/getInterface';
        return Ajax.save(url);
    },
    queryItemsByHostId(hostid) {
        const url = '/dirms/monitor/item/get/sql/' + (hostid ? hostid : 0);
        return Ajax.query(url);
    },
    queryItemById(itemid) {
        const url = '/dirms/monitor/item/get/sql/item/' + (itemid ? itemid : 0);
        return Ajax.query(url);
    },
    queryItemHistoryByItemId(itemId, valueType) {
        const url = '/dirms/monitor/item/getItemHistory/' + (itemId ? itemId : 0) + '/' + (valueType ? valueType : -1);
        return Ajax.query(url);
    },
    queryExchangerHost() {
        const url = '/dirms/monitor/application/getExchanger'
        return Ajax.save(url);
    },
    queryMapLinksByNodeid(mapid, nodeid) {
        const url = '/dirms/monitor/sysmap/getLink/' + mapid + '/' + nodeid;
        return Ajax.save(url);
    },
    querySysmapBaseInfoByType(sysmapType) {
        const url = '/dirms/monitor/sysmap/getSysmapByType/' + sysmapType;
        return Ajax.save(url);
    },
    pageQuerySysmapBaseInfo(pageNo, pageSize) {
        const url = '/dirms/monitor/sysmap/pagequery/' + pageNo + '/' + pageSize;
        return Ajax.query(url);
    },
    updateSysmapBaseInfo(sysmap) {
        const url = '/dirms/monitor/sysmap/updateSysmap';
        return Ajax.save(url, sysmap, false);
    },
    createSysmap(sysmap) {
        const url = '/dirms/monitor/sysmap/create';
        return Ajax.save(url, sysmap, false);
    },
    syncCreateSysmap(sysmap, callback) {
        const url = '/dirms/monitor/sysmap/create';
        return Ajax.syncQuery(url, sysmap, callback);
    },
    deleteSysmap(sysmapid) {
        const url = '/dirms/monitor/sysmap/delete/' + sysmapid;
        return Ajax.save(url);
    },
    syncDeleteSysmap(sysmapid, callback) {
        const url = '/dirms/monitor/sysmap/delete/' + sysmapid;
        return Ajax.syncQuery(url, {}, callback);
    },
    deleteSysmaps(sysmapids) {
        const url = '/dirms/monitor/sysmap/deleteTopos';
        return Ajax.save(url, sysmapids, false);
    },
    createMapElement(elementList) {
        const url = '/dirms/monitor/sysmap/add/element';
        return Ajax.save(url, elementList, false);
    },
    addMapLink(link) {
        const url = '/dirms/monitor/sysmap/add/link';
        return Ajax.save(url, link, false);
    },
    addMapLinks(links) {
        const url = '/dirms/monitor/sysmap/add/links';
        return Ajax.save(url, links, false);
    },
    deleteMapElement(selementid) {
        const url = '/dirms/monitor/sysmap/delete/element/' + selementid;
        return Ajax.save(url);
    },
    deleteMapLink(linkid) {
        const url = '/dirms/monitor/sysmap/delete/link/' + linkid;
        return Ajax.save(url);
    },
    queryIPs(hostid) {
        const url = '/dirms/monitor/sysmap/getIPs/' + hostid;
        return Ajax.save(url);
    },
    queryVlanAndIp(hostid) {
        const url = '/dirms/monitor/sysmap/vlan/ip/' + hostid;
        return Ajax.save(url);
    },
    autoCreateSysmap(sysmapid, exchangerData) {
        const url = '/dirms/monitor/sysmap/autoCreateSysmap/' + sysmapid;
        return Ajax.save(url, exchangerData, false);
    },
    queryHostByName(hostname) {
        let host = {};
        host.name = hostname;
        const url = '/dirms/monitor/host/getByHost';
        return Ajax.save(url, host, false);
    },
    queryHostById(hostid, callback) {
        const url = '/dirms/monitor/host/getById/' + hostid;
        return Ajax.syncQuery(url, {}, callback);
    },
    getHostIdToIncomingAndOutgoingData() {
        const url = '/dirms/monitor/sysmap/getHostIdToIncomingAndOutgoingData';
        return Ajax.query(url);
    },
    itemHistory(itemid, startTimeStamp, endTimeStamp, params) {
        const url = '/dirms/monitor/history/getbytime/' + itemid + '/' + startTimeStamp + '/' + endTimeStamp
        return Ajax.query(url, params);
    },
    itemAlert(itemid, startTimeStamp, endTimeStamp, params) {
        const url = '/dirms/monitor/item/get/alert/' + itemid + '/' + startTimeStamp + '/' + endTimeStamp
        return Ajax.query(url, params);
    }
    // queryHostById(hostid) {
    //   const url = '/dirms/monitor/host/getById/' + hostid;
    //   return Ajax.save(url);
    // }
}
